package algorithms.dynamicProgram;

import java.util.ArrayList;
import java.util.List;

public class LeetCode_119 {

    public static void main(String[] args) {
        List<Integer> generate = getRow(3);
        for (Integer integers : generate) {
            System.out.print(integers + "\t");
        }
    }

    public static List<Integer> getRow(int rowIndex) {
        List<Integer> res = new ArrayList<>();
        for (int i = 0; i <= rowIndex; i++) {
            List<Integer> cur = new ArrayList<>();
            for (int j = 0; j <= i; j++) {
                if (j == 0 || i == j) {
                    cur.add(1);
                } else {
                    cur.add(res.get(j - 1) + res.get(j));
                }
            }
            res = cur;
        }
        return res;

    }
}
